﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
	<title>Browse Files</title>
	@Cms.ScriptInclude("Themes/Admin/Scripts/jquery-1.7.min.js")
	@Cms.ScriptInclude("Themes/Admin/Scripts/jquery-ui-1.8.16.custom.min.js")
	@Cms.ScriptInclude("Themes/Admin/Scripts/elfinder/js/elfinder.min.js")
	@Cms.ScriptInclude("Themes/Admin/Scripts/elfinder/js/proxy/elFinderSupportVer1.js")
	
	@Cms.CssLink("Themes/Admin/Styles/admin.css")
	@Cms.CssLink("Themes/Admin/Styles/jquery-ui/jquery-ui-1.8.16.custom.css")
	@Cms.CssLink("Themes/Admin/Scripts/elfinder/css/elfinder.min.css")
	@Cms.CssLink("Themes/Admin/Scripts/elfinder/css/theme.css")
	
	<script type="text/javascript" src="@Cms.Content("Themes/Admin/Scripts/tiny_mce/tiny_mce_popup.js")"></script>

	<script type="text/javascript">
		var FileBrowserDialogue = {
			init: function() {
				// Here goes your code for setting your custom things onLoad
			},
			mySubmit: function(URL) {
				var win = tinyMCEPopup.getWindowArg('window');

				// pass selected file path to TinyMCE
				win.document.getElementById(tinyMCEPopup.getWindowArg('input')).value = URL;

				// are we an image browser?
				if (typeof(win.ImageDialog) != 'undefined') {
					// update image dimensions
					if (win.ImageDialog.getImageData) {
						win.ImageDialog.getImageData();
					}
					// update preview if necessary
					if (win.ImageDialog.showPreviewImage) {
						win.ImageDialog.showPreviewImage(URL);
					}
				}

				// close popup window
				tinyMCEPopup.close();
			}
		};

		tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);

		$(document).ready(function() {
			$('#filemanager').elfinder({
				url: "@Url.Action("Finder", "Files")",
				transport: new elFinderSupportVer1(),
				height: 600,
				uiOptions: {
					toolbar: [
						['back', 'forward'],
						['mkdir', 'upload'],
						['open', 'download', 'getfile'],
						['info'],
						['quicklook'],
						['copy', 'cut', 'paste'],
						['rm'],
						['rename', 'resize'],
						['view'],
						['help']
					]
				},
				contextmenu: {
				// navbarfolder menu
					navbar:
						['open', '|', 'copy', 'cut', 'paste', '|', 'rm', '|', 'info'],
					// current directory menu
					cwd:
						['back', '|', 'upload', 'mkdir', 'paste', '|', 'info'],
					// current directory file menu
					files:
						['getfile', '|', 'open', 'quicklook', '|', 'download', '|', 'copy', 'cut', 'paste', '|', 'rm', '|', 'edit', 'rename', 'resize', '|', '|', 'info']
				},
				getfile: {
					onlyURL: true,
					multiple: false,
					folders: false
				},
				getFileCallback: function(url) {
					FileBrowserDialogue.mySubmit(url);
				}
			}).elfinder("instance");
		});
	</script>
</head>
<body>
    <div id="filemanager"></div>
</body>
</html>
